package com.it.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.it.FollowingService;
import com.it.dao.FollowingMapper;
import com.it.pojo.Following;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class FollowingServiceImpl implements FollowingService {
    @Resource
    private FollowingMapper followingMapper;

    @Override
    public int save(Integer userId, Integer followId) {
        Following following = new Following();
        Date date = new Date();
        following.setGmtCreate(date);
        following.setGmtModified(date);
        following.setUserFollowingId(followId);
        following.setUserId(userId);
        return followingMapper.insert(following);
    }

    @Override
    public boolean checkFollow(Integer userId, Integer currentUserId) {
        Following following = followingMapper.checkFollow(userId, currentUserId);
        if (following != null) {
            return true;
        }
        return false;
    }

    @Override
    public int updateFollow(Integer userId, Integer currentUserId) {


        return followingMapper.deleteFollow(userId, currentUserId);

    }
}
